*
* Table B4: Program characteristics and dominated choices: heterogeneity
*
* Input table: 
*	"${data_program_level_tidy}"
*
* Output file: 
*	/results/TableB4.tex
*

use "${data_program_level_tidy}", clear
keep if year <= 2011

qui reg dominated_choice priority_score_cutoff_std ///
	priority_score_cutoff_missing i.year, r
est store est1

reg dominated_choice ba i.year, r
est store est2

reg dominated_choice full_time i.year, r
est store est3

reg dominated_choice capital_program county_capital i.year, r
est store est4

reg dominated_choice field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15 field_of_study_13 i.year if year <= 2011, r
est store est5

reghdfe dominated_choice priority_score_cutoff_std ///
	priority_score_cutoff_missing ba full_time capital_program ///
	county_capital field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15 field_of_study_13 i.year, ///
	noabsorb vce(robust)
est store est6

reghdfe dominated_choice priority_score_cutoff_std priority_score_cutoff_missing ba full_time capital_program ///
	county_capital field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15 field_of_study_13 i.year, ///
	absorb(i.id) vce(robust)
est store est7

esttab est1 est2 est3 est4 est5 est6 est7 ///
	using "${result_dir}/TableB4.tex", ///
	drop(_cons *_missing) b(4) se(4) r2 indicate("Year FE = *year") ///
	stat(r2, fmt(%18.2g) ///
	labels("R-squared")) ///
	label star(* 0.10 ** 0.05 *** 0.01) replace noomitted nogaps f noobs ///
	nomtitles nonumbers nolines ///
	order(priority_score_cutoff_std priority_score_cutoff_missing ba full_time ///
		capital_program county_capital field_of_study_1 field_of_study_9 field_of_study_3 ///
	field_of_study_5 field_of_study_8 field_of_study_11 field_of_study_2 ///
	field_of_study_6 field_of_study_10 field_of_study_14 field_of_study_12 ///
	field_of_study_7 field_of_study_15)

* ------------------------------------------------------------------------------	
* Table notes:
count
local n_obs = r(N)
by id, sort: gen nvals = _n == 1 
count if nvals
local n_rols = r(N)
drop nvals
di "The number of applications is " `n_obs' " , which corresponds to " `n_rols' " ROLs."

qui sum dominated_choice
di "The share of dominated choices (on the application-level) is " round(r(mean)*100, 0.1) " percent in this sample."


